package com.yuexun.beilunpatient.ui.satisfaction.adapter;

import android.os.Bundle;
import android.view.View;
import android.widget.AbsListView;
import android.widget.TextView;

import com.yuexun.beilunpatient.R;
import com.yuexun.beilunpatient.baselistener.ICallBackListener;
import com.yuexun.beilunpatient.ui.satisfaction.bean.SatisfactionDateBean;

import org.kymjs.kjframe.widget.AdapterHolder;
import org.kymjs.kjframe.widget.KJAdapter;

import java.util.Collection;

/**
 * Created by chenss on 2018/4/12 0012.
 */

public class SatisfactionListAdapter extends KJAdapter<SatisfactionDateBean> {

    ICallBackListener backListener;

    public void setBackListener(ICallBackListener backListener) {
        this.backListener = backListener;
    }

    public SatisfactionListAdapter(AbsListView view, Collection<SatisfactionDateBean> mDatas, int itemLayoutId) {
        super(view, mDatas, itemLayoutId);
    }

    @Override
    public void convert(AdapterHolder helper, SatisfactionDateBean item, boolean isScrolling, final int position) {
        super.convert(helper, item, isScrolling, position);
        TextView textView = helper.getView(R.id.tv_survey_start);
        textView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bundle bundle = new Bundle();
                bundle.putInt("position", position);
                backListener.callback(bundle);
            }
        });
        helper.setText(R.id.tv_survey_area, item.getAeraName());
        helper.setText(R.id.tv_survey_unit, item.getHospName());
        helper.setText(R.id.tv_survey_title, item.getSatisfactionName());
        helper.setText(R.id.tv_survey_name, item.getTypeName());
        if(item.getExamStatus() == 1){
            helper.setText(R.id.tv_survey_status, "未开始");
        }else if(item.getExamStatus() == 2){
            helper.setText(R.id.tv_survey_status, "进行中");
        }else if(item.getExamStatus() == 3){
            helper.setText(R.id.tv_survey_status, "已结束");
        }
    }
}
